﻿using System;
using System.IO;

namespace Com.VikingErik.Mvc.ResumingDownloads
{
    public class ResumableFilePathResult : ResumableDownloadResult
    {
        private FileInfo MediaFile { get; set; }

        public ResumableFilePathResult(ResumableDownloadRequest resumableDownloadRequest, string filePath)
            : base (resumableDownloadRequest)
        {
            MediaFile = new FileInfo(filePath);
        }

        public ResumableFilePathResult(ResumableDownloadRequest resumableDownloadRequest, string filePath, string contentType)
            : base(resumableDownloadRequest, contentType)
        {
            MediaFile = new FileInfo(filePath);
        }

        protected override Stream FileContent
        {
            get
            {
                return MediaFile.OpenRead();
            }
        }

        protected override DateTimeOffset? LastModified
        {
            get
            {
                return MediaFile.LastWriteTimeUtc;
            }
        }
    }
}
